/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kungkhies.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author clayton
 */
@Entity 
@Table(name = "alias_term")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "AliasTerm.findAll", query = "SELECT a FROM AliasTerm a"),
    @NamedQuery(name = "AliasTerm.findByAliasId", query = "SELECT a FROM AliasTerm a WHERE a.aliasId = :aliasId"),
    @NamedQuery(name = "AliasTerm.findByAliasName", query = "SELECT a FROM AliasTerm a WHERE a.aliasName = :aliasName")
})
public class AliasTerm implements Serializable 
{
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "alias_id")
    private Long aliasId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 256)
    @Column(name = "alias_name")
    private String aliasName;
    @ManyToMany(mappedBy = "aliasTermCollection")
    private Collection<Category> categoryCollection;

    public AliasTerm()
    {
    }

    public AliasTerm(Long aliasId)
    {
        this.aliasId = aliasId;
    }

    public AliasTerm(Long aliasId, String aliasName)
    {
        this.aliasId = aliasId;
        this.aliasName = aliasName;
    }

    public Long getAliasId()
    {
        return aliasId;
    }

    public void setAliasId(Long aliasId)
    {
        this.aliasId = aliasId;
    }

    public String getAliasName()
    {
        return aliasName;
    }

    public void setAliasName(String aliasName)
    {
        this.aliasName = aliasName;
    }

    @XmlTransient
    public Collection<Category> getCategoryCollection()
    {
        return categoryCollection;
    }

    public void setCategoryCollection(Collection<Category> categoryCollection)
    {
        this.categoryCollection = categoryCollection;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (aliasId != null ? aliasId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AliasTerm))
        {
            return false;
        }
        AliasTerm other = (AliasTerm) object;
        if ((this.aliasId == null && other.aliasId != null) || (this.aliasId != null && !this.aliasId.equals(other.aliasId)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "com.kungkhies.persistence.entities.AliasTerm[ aliasId=" + aliasId + " ]";
    }

}
